﻿
<%--
  *  File:    BunchnoManage.jsp
  *  @Author: KevinFan
  *  Date:    2011/8/2
  *
  *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
  *  All rights reserved.
  *
  *  This software is the confidential and proprietary information of Oval
  *  Technologies, Inc. ("Confidential Information").  You shall not
  *  disclose such Confidential Information and shall use it only in
  *  accordance with the terms of the license agreement you entered into
  *  with Oval.
 --%>
 <%@ page import="java.text.*" %>
  <%@ page import="java.util.*" %>
<%@ page import="java.text.DecimalFormat"%>
<%@ page import="java.lang.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>

<%
   Category cat = Category.getInstance("jsp.BunchnoManage");
   String strModuleName = "TDR";
   String privilegeCode = "A0902";
   String contextPath = request.getContextPath();
 %>
<%@ include file="/inc/CommonHeader.inc"%>
<%@ include file="/inc/OvalLocationDefault.inc"%>
<%@ include file="/rpt/ReportURL.inc"%>
<html>
<iframe name="summaryfrm" scrolling="no" frameborder="0"
	style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
<head>
<title>CustomerCollateEdit</title>
<PageFlow:CheckPageFlow pageName="p_getbunchnodetailsummarynew" />
<%@ include file="/inc/CatchError.inc"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript"
	src="<%=contextPath %>/js/SummaryDivision.js"></script>
<link rel="stylesheet"
	href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css"
	type="text/css">
<script language="JavaScript"
	src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript"
	src="<%=contextPath %>/js/opal2/mootools.js"></script>
<%@ include file="/inc/SummaryDivision.inc"%>
<%@ include file="/inc/NewCalendar.inc"%>
<%
 HashMap userinfo = (HashMap) session.getAttribute("userinfo");
 String  issalesman = (String) userinfo.get("issalesman");
   Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
   HashMap onehash = (HashMap)pageContext.getAttribute("onehash");
   if(totalsummary == null)totalsummary = new Vector();
   if(onehash == null)onehash = new HashMap();
   String strSkipto= (String)onehash.get("skipto");
   int n = totalsummary.size();
 %>
<script><!--
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform)return;
  if(errorflag == 1){
	alert("密码/监管码格式不正确！");
	return;
  }
  if(cform.serdetailtype.value!=4 && (cform.serproductid.value=="" || cform.serproductid.value==null) && cform.serdatacode.value.length==9){
	alert("请选择所查询产品！");
	return;
  }
  editform.action = "BunchnoSearch.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function page_toSearch(){
    //check_porscode();
    //alert(document.serbunchnotype.value);
	if(!checkForm(document.cform))return;
	serdatacode = cform.serdatacode.value;
	serbunchnotype=cform.serbunchnotype.value;
	//handledata=cform.handledata.value;
	cform.seritmecode.value=serdatacode.substr(0,5);
	page_summary('search');
}

function page_change(){
	serdatatype = cform.serdetailtype.value;
	if(serdatatype==4){
		document.getElementById("hidtext1").style.display = "block";
		document.getElementById("hidtext2").style.display = "block";
		document.getElementById("hidtext3").style.display = "none";
		document.getElementById("hidtext4").style.display = "none";
		cform.serproductid.value="";
		cform.serproductcode.value="";
		cform.serproductname.value="";
		document.getElementById("td_set").style.width="50%";
		cform.serbatchno.command="notnull";
		check_porscode();
	}else{
		document.getElementById("hidtext1").style.display = "none";
		document.getElementById("hidtext2").style.display = "none";
		document.getElementById("td_set").style.width="60%";
		cform.serbatchno.command="";
		cform.serbatchno.value="";
		check_porscode();
	}
}

var isHidden;
function frm_select(e){
	isHidden = "block";
	var _target = getPosition(e);
    var _obj = document.getElementById("summaryfrm");
    _obj.style.left = _target.x;
    _obj.style.top = _target.y + e.clientHeight;
    _obj.style.height="300px";
    _obj.style.width="530px";
    _obj.style.zIndex = 5000;
    _obj.style.display = "block";
}
//getbusinessarea
function page_getpriviceoffice(){
	var objdeptcode=eval("cform.regionid");
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , objdeptcode.value , "Integer");
	datahandler.getResultFromVector("resultproviceoffice","proviceofficename","proviceofficecode","document.cform.proviceofficelist");
	datahandler.add_job("j_doctorchufangliangdoc");
	datahandler.runDataHandler();
  }

function page_getbusinessarea(){
	var regionid = document.cform.regionid.value;
	var objdeptcode=eval("cform.proviceofficelist");
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , regionid, "Integer");
	datahandler.add_params("proviceofficelist" , objdeptcode.value , "String");
	datahandler.getResultFromVector("resultbusinessarea","businessareaname","businessareacode","document.cform.businessarealist");
	datahandler.add_job("j_doctorchufangliangdoc");
	datahandler.runDataHandler();
 }
 
function frm_select(e,flag){
	switchtype=flag;
	isHidden = "block";
	var _target = getPosition(e);
    var _obj = document.getElementById("summaryfrm");
    _obj.style.left = _target.x;
    _obj.style.top = _target.y + e.clientHeight;
    _obj.style.height="250px";
    _obj.style.width="530px";
    _obj.style.zIndex = 5000;
    _obj.style.display = "block";
	var strUrl = "";	
	if(flag==1 || flag==4){
		strUrl = "<%=contextPath %>/tdr/datatypein/OrgSelectPop.jsp?maxitem=8&globalpccode=1&<%= OvalTools.randomURL() %>";
	}else if(flag==2 || flag==5){
		if(flag==5)_obj.style.left = _target.x-530;
		strUrl = "<%=contextPath %>/tdr/datatypein/OrgSelectPop.jsp?maxitem=8&globalpccode=2&<%= OvalTools.randomURL() %>";
	}else if(flag==3 || flag==6){
		_obj.style.height="300px";
		strUrl = "<%=contextPath %>/tdr/datatypein/ProdSelectPop.jsp?maxitem=10&<%= OvalTools.randomURL() %>";
	}
    document.summaryfrm.location.href = strUrl;
}

//salesman
function popRep() {
	var regionid=cform.regionid.value;
	var proviceofficecode = document.cform.proviceofficelist.value;
	var businessareacode = document.cform.businessarealist.value;
	//alert(regionid+"|"+proviceofficeid+"|"+areaid+"|");
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "<%=contextPath %>/tdr/dataverify/SalesPopWindow.jsp?<%= OvalTools.randomURL() %>&regionid="+regionid+"&proviceofficecode="+proviceofficecode+"&businessareacode="+businessareacode;
	popwindow = window.open(url, "newwindow", status);
  }
  
function getPosition(e) {
        var left = 0;
        var top = 0;
        while (e.offsetParent) {
            left += e.offsetLeft + (e.curentStyle? (parseInt(e.curentStyle.borderLeftWidth).NaN0()):0);
            top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
            e = e.offsetParent;
        }
        left += e.offsetLeft + (e.curentStyle ? (parseInt(e.curentStyle.borderLeftWidth)).NaN0() : 0);
        top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
        return {x:left, y:top};
}
function closeItemSelect(evt)
{
	var _obj = document.getElementById("summaryfrm");
	if(isHidden == "block"){
		isHidden = "none";
	}else{
		_obj.style.display = "none";
	}
	evt = evt || window.event;
        var _target = evt.target || evt.srcElement;
        if (!_target.getAttribute("Author") && _target != inputObj && _target != targetObj) {
            getObjById("Calendar").style.display = "none";
            getObjById("CalendarFrm").style.display = "none";
        }
}

function hiddenFrm(){
	document.getElementById("summaryfrm").style.display = "none";
}

document.onclick=closeItemSelect;   

function page_setProduct(id,code,name,price,spec){	
		cform.serproductid.value=id;
		cform.serproductcode.value=code;
		cform.serproductname.value=name;
	hiddenFrm();
}

var errorflag=0;

function check_porscode() 
{ 
	porscode = cform.serdatacode.value;
	datatype = cform.serdetailtype.value;
	obj1 = cform.serdetailtype;
	if(datatype==-1){
		alert("请先选择包装类型！");
		obj1.focus();
		return;
	}
	if(datatype==4){
		if(porscode!=""){
			var patrn = /^[0-9]{10}$/;
			if(!patrn.exec(porscode)) { 
				alert("密码格式应为10位数字！");
				errorflag=1;
				cform.serdatacode.focus();
			}else{
				errorflag=0;
			}
		}
	}else{
		if(porscode!=""){
			var patrn1 = /^[0-9]{20}$/; 
			var patrn2 = /^[0-9]{9}$/;
			//if(!patrn1.exec(porscode) && !patrn2.exec(porscode)) { 
			if(!patrn1.exec(porscode)) { 
				alert("监管码格式应为20位数字!");
				errorflag=1;
				cform.serdatacode.focus();
			}else{
				errorflag=0;
				if(patrn2.exec(porscode)){
					document.getElementById("hidtext3").style.display = "block";
					document.getElementById("hidtext4").style.display = "block";
					document.getElementById("td_set").style.width="40%";
				}else{
					document.getElementById("hidtext3").style.display = "none";
					document.getElementById("hidtext4").style.display = "none";
					document.getElementById("td_set").style.width="60%";
					cform.serproductid.value="";
					cform.serproductcode.value="";
					cform.serproductname.value="";
				}
			}
		}
	}
	
} 

function setOrg(id,name,code)
{
	if(switchtype==1){
		cform.sershipfrom.value=id;
		cform.sershipfromcode.value=code;
		cform.sershipfromname.value=name;
	}else if(switchtype==2){
		cform.sershipto.value=id;
		cform.sershiptocode.value=code;
		cform.sershiptoname.value=name;
	}else if(switchtype==4){
		cform.shipfrom.value=id;
		cform.shipfromcode.value=code;
		cform.shipfromname.value=name;
	}else if(switchtype==5){
		cform.shipto.value=id;
		cform.shiptocode.value=code;
		cform.shiptoname.value=name;
	}
	hiddenFrm();
}

function page_setProduct(id,code,name,price,spec){	
    //alert(id+" "+code+" "+name);
	if(switchtype==3){
		cform.serproductid.value=id;
		cform.serproductcode.value=code;
		cform.serproductname.value=name;
	}else if(switchtype==6){
		cform.productid.value=id;
		cform.productcode.value=code;
		cform.productname.value=name;
	}
	hiddenFrm();
}
function page_clear(){
   
	cform.sershipfrom.value=""; cform.sershipfromcode.value=""; cform.sershipfromname.value=""; cform.sershipto.value=""; cform.sershiptocode.value=""; cform.sershiptoname.value=""; cform.serdate1.value=""; cform.serdate2.value=""; cform.serproductid.value=""; cform.serproductcode.value=""; cform.serproductname.value="";
 cform.serbatchno.value=""; cform.serdatacode.value="";
}
function SetSalesMan(id,code,name){
	cform.userids.value=id;
	cform.employeecode.value=code;
	cform.employeename.value=name;
}

document.onclick=closeItemSelect;   
--></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
<input type="hidden" name="pagename" value="p_getbunchnodetailsummarynew">
<input type="hidden" name="actionname" /> <input type="hidden"
	name="errortype" /> <input type="hidden" name="pageaction"> <custom:hidden
	property="maxitem" /> <input type="hidden" name="maker"
	value="<custom:write property="userid" name="userinfo" scope="session"/>" />
<%@ include file="/inc/PageLocation.inc"%>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td>
		<table width="100%" cellspacing="5" cellpadding="0" border="0">
			<tr>
				<td class="td_right" width="5%"><%= "物流类型" + label.getLabelName("L_Colon") %></td>
				<td class="td_left" width="20%"><custom:selectdic
					dictType="LogisticsType" property="serbunchnotype"
					defaultValue="------" defaultValueCost="" valueCriteria="1,2,3" /></td>
				<td class="td_right" width="5%"><%= "出货方" + label.getLabelName("L_Colon") %></td>
				<td class="td_left" width="20%"><custom:hidden
					property="sershipfrom" /> <custom:text property="sershipfromcode"
					size="10" readonly="true" /> <a
					onclick="javascript:javascript:frm_select(this,1);"><custom:button
					type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> <custom:text
					property="sershipfromname" size="15" readonly="true" /></td>
				<td class="td_right" width="5%"><%= "进货方" + label.getLabelName("L_Colon") %></td>
				<td class="td_left" width="20%"><custom:hidden property="sershipto" />
				<custom:text property="sershiptocode" size="10" readonly="true" />
				<a onclick="javascript:javascript:frm_select(this,2);"><custom:button
					type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> <custom:text
					property="sershiptoname" size="15" readonly="true" /></td>
				<td class="td_right">&nbsp;</td>
				</td>
				<td class="td_left" width="20%">&nbsp;</td>
				<td>&nbsp;</td>
				<td id="td_set" class="td_left" width="60%">
			</tr>
			<%-----------------------第二行---------------------%>
			 <%
                SimpleDateFormat formatter1 = new SimpleDateFormat ("yyyy-MM-dd");
                String str_date_end=formatter1.format(new Date());
                
              %>
              <%
              Calendar curCal = Calendar.getInstance();
              SimpleDateFormat datef=new SimpleDateFormat ("yyyy-MM-dd");
              curCal.set(Calendar.DATE, 1);
              curCal.roll(Calendar.DATE, -1);
              Date endTime = curCal.getTime();
              //String eTime = datef.format(endTime) + " 23:59:59";
              String eTime = datef.format(endTime);
              
              curCal.set(Calendar.DAY_OF_MONTH, 1);
              Date beginTime = curCal.getTime();
              String sTime = datef.format(beginTime);
              %>
			<tr>
				<td class="td_right"><%= "发货日期" + label.getLabelName("L_Colon") %></td>
				<td class="td_left"><custom:text property="serdate1" size="10"
					readonly="true" value="<%=sTime %>"/> <a
					onclick="javascript:c.show(this,'cform.serdate1','yyyy-MM-dd')"><input
					type=button class="button3" value="*"></a></a>-- <custom:text
					property="serdate2" size="10" readonly="true" value="<%=eTime %>" /> <a
					onclick="javascript:c.show(this,'cform.serdate2','yyyy-MM-dd')"><input
					type=button class="button3" value="*"></a></td>
				<td class="td_right"><%= "产品" + label.getLabelName("L_Colon") %></td>
				<td class="td_left"><custom:hidden property="serproductid" /> <custom:text
					property="serproductcode" size="10" readonly="true" /> <a
					onclick="javascript:frm_select(this,3);"><custom:button type="3"
					label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> <custom:text
					property="serproductname" size="15" readonly="true" /></td>
				<td class="td_left"><%="包装类型" +  label.getLabelName("L_Colon") %></td>
				<td class="td_left"><custom:selectdic dictType="PackagType"
					property="serdetailtype" defaultValue="------"
					defaultValueCost="-1" label="L_PackageType"
					onchange="javascript:page_change();" command="notnull" /></td>
				<td class="td_right">&nbsp;</td>
				<td class="td_left">&nbsp;</td>
				<td>&nbsp;</td>
				<td id="td_set" class="td_left" width="60%">
			</tr>
			<%-----------------------第三行---------------------%>
			<tr>
				<td class="td_right">&nbsp;<span style="display:none" id="hidtext1"><%="批号" +  label.getLabelName("L_Colon") %></span></td>
				<td class="td_left"><span style="display:none" id="hidtext2"> <custom:text
					property="serbatchno" size="20" label="L_LotNumber" /></span></td>
				<td class="td_right"><%="密码/监管码" +  label.getLabelName("L_Colon") %></td>
				<td class="td_left"><!--  <custom:text property="serdatacode" size="25"
					 label="L_PassWordSupervis"
					onchange="check_porscode()" /> <custom:hidden
					property="seritmecode" />--> <custom:text property="serdatacode"
					size="25" label="L_PassWordSupervis" onchange="check_porscode()"
					command="notnull" /> <custom:hidden property="seritmecode" /></td>
				<td class="td_right" style="display:none" id="hidtext3"><!--<%= label.getLabelName("L_Product") + label.getLabelName("L_Colon") %>--></td>
				<td class="td_left" style="display:none" id="hidtext4"><!--<custom:hidden
					property="serproductid" /> <custom:text property="serproductcode"
					size="10" readonly="true" label="L_Product" /> <a
					onclick="javascript:frm_select(this);"><custom:button
					property="buttoner" type="3" label="L_Asterisk" imgsrc="flash.gif"
					border="0" /></a> <custom:text property="serproductname" size="15"
					readonly="true" />--></td>
				<td class="td_right">&nbsp;</td>
				<td class="td_left">&nbsp;</td>
				<td><a onclick="javascript:page_toSearch();"><img
					src="/oval/images/cn/go.gif" border="0"></a>
				<button type="button" onclick="page_clear()" class="button1"
					name="re" value="clear" style="width:60"><%=label.getLabelName("L_Clear") %></button>
				</td>
				<td id="td_set" class="td_left" width="60%"></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<table width="100%" border="1" cellpadding="0"
			bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0"
			align="center">
			<tr class="deepblue-left">
				<td class="title_center">产品编码</td>
				<td class="title_center">产品名称</td>
				<td class="title_center">批号</td>
				<td class="title_center">密码/基药监管码</td>
				<td class="title_center">物流类型</td>
				<td class="title_center">发货日期</td>
				<td class="title_center">出货方</td>
				<td class="title_center">进货方</td>
				<td class="title_center">包装类型</td>
				<td class="title_center">实际盒数</td>
				<td class="title_center">拼装类型</td>
			</tr>
			<%if(strSkipto != null){%>
			<tr onMouseOver="this.className='tr-over'"
				onMouseOut="this.className='td-listrom'" class="td-listrom">
				<td rowspan="<%=n+1%>"><custom:write name="onehash"
					property="prodcode" nbsp="true" /></td>
				<td rowspan="<%=n+1%>"><custom:write name="onehash"
					property="prodname" nbsp="true" /></td>
				<td rowspan="<%=n+1%>"><custom:write name="onehash"
					property="batchno" nbsp="true" /></td>
				<td rowspan="<%=n+1%>"><custom:write name="onehash"
					property="datacode" nbsp="true" /></td>
				<td><custom:write name="onehash" dictType="LogisticsType"
					property="batchnoype" nbsp="true" /></td>
				<td><custom:write name="onehash" property="docdate" nbsp="true" /></td>
				<td><custom:write name="onehash" property="skipfrom" nbsp="true" /></td>
				<td><custom:write name="onehash" property="skipto" nbsp="true" /></td>
				<td><custom:write name="onehash" dictType="PackagType"
					property="datatype" nbsp="true" /></td>
				<td><custom:write name="onehash" property="qtytype" nbsp="true" /></td>
				<td><custom:write name="onehash" dictType="AssemblyType"
					property="assemblytype" nbsp="true" /></td>
			</tr>
			<%}%>
			<%
                        String strClassType="";
                        int i = 0;
						HashMap hash = null; 
						String strVal = "";
                 %>
			<logic:iterate id="onedetail" collection="<%= totalsummary %>">
				<%//show different colours in turns
                     if(i%2 == 1)
                         {
                             strClassType = "td-listrom";
                         }else{
                             strClassType = "none";
                         }
                     i++;
                 %>
				<tr onMouseOver="this.className='tr-over'"
					onMouseOut="this.className='<%= strClassType %>'"
					class="<%= strClassType %>">
					<%if(strSkipto == null && i==1){%>
					<td rowspan="<%=n%>"><custom:write name="onedetail"
						property="prodcode" nbsp="true" /></td>
					<td rowspan="<%=n%>"><custom:write name="onedetail"
						property="prodname" nbsp="true" /></td>
					<td rowspan="<%=n%>"><custom:write name="onedetail"
						property="batchno" nbsp="true" /></td>
					<td rowspan="<%=n%>"><custom:write name="onedetail"
						property="datacode" nbsp="true" /></td>
					<%}%>
					<td><custom:write name="onedetail" dictType="LogisticsType"
						property="batchnoype" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="docdate" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="skipfrom" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="skipto" nbsp="true" /></td>
					<td><custom:write name="onedetail" dictType="PackagType"
						property="datatype" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="qtytype" nbsp="true" /></td>
					<td><custom:write name="onedetail" dictType="AssemblyType"
						property="assemblytype" nbsp="true" /></td>
				</tr>
			</logic:iterate>
		</table>
		</td>
	</tr>
</table>
</form>
<script>
	document.summaryfrm.location.href = "<%=contextPath %>/tdr/datatypein/ProdSelectPop.jsp?maxitem=10&<%= OvalTools.randomURL() %>";
	if(cform.serdetailtype.value!=-1){
		if(cform.serdetailtype.value==4){
			document.getElementById("hidtext1").style.display = "block";
			document.getElementById("hidtext2").style.display = "block";
			document.getElementById("td_set").style.width="50%";
		}else{
			if(cform.serdatacode.value.length==9){
				document.getElementById("hidtext3").style.display = "block";
				document.getElementById("hidtext4").style.display = "block";
				document.getElementById("td_set").style.width="40%";
				cform.serbatchno.command="";
			}
		}
	}
</script>
</body>
</html>


